import request from '@/utils/request';

export async function getInspectionTemplateByPage(params: any) {
  return request('/api/quality/getInspectionTemplateByPage', {
    method: 'POST',
    data: params,
  });
}

// 新建模板
export async function addInspectionTemplate(params: any) {
  return request('/api/quality/addInspectionTemplate', {
    method: 'POST',
    data: params,
  });
}

export async function updateInspectionTemplate(params: any) {
  return request('/api/quality/updateInspectionTemplate', {
    method: 'POST',
    data: params,
  });
}

export async function delInspectionTemplate(params: any) {
  return request('/api/quality/delInspectionTemplate', {
    method: 'POST',
    data: params,
  });
}

export async function exportInspectionTemplate(params: any) {
  return request('/api/quality/exportInspectionTemplate', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function getInspectionType(params: any) {
  return request('/api/quality/getInspectionType', {
    method: 'POST',
    data: params,
  });
}

export async function getTemplateInspectionItem(params: any) {
  return request('/api/quality/getTemplateInspectionItem', {
    method: 'POST',
    params: {
      inspectionTemplateId: params,
    },
  });
}

export async function getInspectionTemplateMasterItem(params: any) {
  return request('/api/quality/getInspectionTemplateMasterItem', {
    method: 'POST',
    params: {
      inspectionTemplateId: params,
    },
  });
}

// 模板名称查重
export async function getInspectionTemplateByNameAndProductType(para: any) {
  return request('/api/quality/getInspectionTemplateByNameAndProductType', {
    method: 'POST',
    data: para,
    params: {
      name: para.name,
      productType: para.productType,
    },
  });
}

// 获取柜体类型
export async function getProductTypeList(params: any) {
  return request('/api/design/getProductTypeList', {
    method: 'POST',
  });
}

// 过程检验判重
export async function checkInspectionTemplateByProductAndProcess(para: any) {
  return request('/api/quality/checkInspectionTemplateByProductAndProcess', {
    method: 'POST',
    data: para,
    params: {
      processName: para.processName,
      productType: para.productType,
    },
  });
}

export default {
  getInspectionTemplateByPage,
  addInspectionTemplate,
  updateInspectionTemplate,
  delInspectionTemplate,
  exportInspectionTemplate,
};
